package com.software.broadcast.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.NetworkInfo;
import android.os.Parcelable;
import android.widget.Toast;

public class NetworkReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        // 获得系统网络广播
        NetworkInfo networkInfo = intent.getParcelableExtra("networkInfo");
        String typeName = networkInfo.getTypeName();
        Toast.makeText(context, "当前使用的网络环境为" + typeName, Toast.LENGTH_SHORT).show();
    }
}